<%@page import="java.sql.*,org.opencms.db.*,org.opencms.main.*"%>
<%  
	String method=request.getParameter("method");
	if(method.equals("sel")){
	java.sql.Connection con = OpenCms.getSqlManager().getConnection("yourdb");
	PreparedStatement pstmt = con.prepareStatement("SELECT `id`,`姓名`,`信件分类`,`标题` FROM mail where `id`=?");  
	String idnum=request.getParameter("id");
	pstmt.setString(1,idnum);
	ResultSet rs;
    rs = pstmt.executeQuery(); 
    while (rs.next()) {
     out.println("<td>"+rs.getString(1)+"</td>"+"<td>"+rs.getString(2)+"</td>"+"<td>"+rs.getString(3)+"</td>"+"<td>"+rs.getString(4)+"</td>");	
    	} 
    rs.close();
    pstmt.close();
	 con.close();
 	}
	else if(method.equals("del")){
	java.sql.Connection con = OpenCms.getSqlManager().getConnection("yourdb");
	PreparedStatement pstmt= con.prepareStatement("delete  FROM mail where `id`=?");  
	String idnum=request.getParameter("id");
	pstmt.setString(1,idnum);
	pstmt.execute(); 
    pstmt.close();
	 con.close();
 	}
	else if(method.equals("add")){
	java.sql.Connection con = OpenCms.getSqlManager().getConnection("yourdb");
	PreparedStatement pstmt= con.prepareStatement("INSERT INTO `mail`(`id`, `姓名`, `信件分类`, `标题`) VALUES (?,?,?,?);");
	String id=request.getParameter("id");
	String name=request.getParameter("name");
	String clas=request.getParameter("clas");
	String title=request.getParameter("title");
	pstmt.setString(1,id);
	pstmt.setString(2,name);
	pstmt.setString(3,clas);
	pstmt.setString(4,title);
	pstmt.execute(); 
    pstmt.close();
	 con.close();
	}
	else if(method.equals("upd")){
	java.sql.Connection con = OpenCms.getSqlManager().getConnection("yourdb");
	PreparedStatement pstmt= con.prepareStatement("UPDATE `mail` SET `姓名`=?,`信件分类`=?,`标题`=? WHERE `id`=?;");  
	String id=request.getParameter("id");
	String name=request.getParameter("name");
	String clas=request.getParameter("clas");
	String title=request.getParameter("title");	
	pstmt.setString(1,name);
	pstmt.setString(2,clas);
	pstmt.setString(3,title);
	pstmt.setString(4,id);
	pstmt.executeUpdate(); 
    pstmt.close();
	 con.close();
	}
	else{
	out.println("<div>请输入method!!!<div>");
	}
   
 %>
 